print("Введите скобочную последовательность: ")
s = input()
s1 = ''
count1 = 0
count2 = 0
count3 = 0
count4 = 0
if s[0] == ']' or s[0] == '}' or s[0] == ')' or s[0] == '>':
    print("False")
else:
    if len(s) % 2 != 0:
        print('False')
    else:
        for el in s:
            if el == '(':
                s1 += el
                count1 += 1
            if el == ')':
                count1 -= 1
                if len(s1) > 0:
                    if s1[len(s1) - 1] == '(':
                        s1 = s1[:-1]
            if el == '[':
                s1 += el
                count2 += 1
            if el == ']':
                count2 -= 1
                if len(s1) > 0:
                    if s1[len(s1) - 1] == '[':
                        s1 = s1[:-1]
            if el == '{':
                s1 += el
                count3 += 1
            if el == '}':
                count3 -= 1
                if len(s1) > 0:
                    if s1[len(s1) - 1] == '{':
                        s1 = s1[:-1]
            if el == '<':
                s1 += el
                count4 += 1
            if el == '>':
                count4 -= 1
                if len(s1) > 0:
                    if s1[len(s1) - 1] == '<':
                        s1 = s1[:-1]
        if len(s1) == 0 and count1 == 0 and count2 == 0 and count3 == 0 and count4 == 0:
            print("True")
        else:
            print("False")
            

